package com.d0318;

public class PersonMeeting implements Runnable{
    static int person = 30;
    static String str=new String();
    @Override
    public void run() {
        while (person>0){
            synchronized (str){
                int num=(int)(Math.random()*30);
                System.out.println(person+"号员工"+Thread.currentThread().getName()+"进入，奖牌号"+num);
                person--;
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }

    public static void main(String[] args) {
        Thread thread=new Thread(new PersonMeeting(),"前门");
        Thread thread1=new Thread(new PersonMeeting(),"后门");
        thread.start();
        thread1.start();
    }
}
